home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------------
- -- Weapon Sub Bomb + Projectile Sub Bomb
- -- Original Carnage Contest Weapon
- -- Script by DC, September 2009, www.UnrealSoftware.de
- --------------------------------------------------------------------------------
-
- -- Setup Tables
- if cc==nil then cc={} end
- cc.subbomb={}
- cc.subbomb.subbomb={}
-
- -- Load & Prepare Ressources
- cc.subbomb.gfx_wpn=loadgfx("weapons/rc.bmp") -- Weapon Image
- setmidhandle(cc.subbomb.gfx_wpn)
- cc.subbomb.gfx_pro=loadgfx("weapons/subbomb.bmp") -- Projectile Image
- setmidhandle(cc.subbomb.gfx_pro)
- cc.subbomb.sfx_attack=loadsfx("sonar.ogg")
-
- --------------------------------------------------------------------------------
- -- Weapon: Sub Bomb
- --------------------------------------------------------------------------------
-
- cc.subbomb.id=addweapon("cc.subbomb","Sub Bomb",cc.subbomb.gfx_pro,0) -- Add Weapon (0 uses)
-
- function cc.subbomb.draw() -- Draw
- setblend(blend_alpha)
- setalpha(1)
- setcolor(255,255,255)
- drawinhand(cc.subbomb.gfx_wpn,7,0)
- -- HUD Positioning
- if weapon_shots==0 then
- hudpositioning(pos_invisible)
- end
- end
-
- function cc.subbomb.attack(attack) -- Attack
- if (weapon_shots<=0) and (weapon_position==1) then
- -- No more weapon switching!
- useweapon(0)
- playsound(cc.subbomb.sfx_attack)
- weapon_shots=weapon_shots+1
- -- Attack
- pid=createprojectile(cc.subbomb.subbomb.id)
- projectiles[pid]={}
- projectiles[pid].x=weapon_x
- projectiles[pid].y=getmapheight()+750
- projectiles[pid].sx=0
- projectiles[pid].sy=-5.0
- -- End Turn
- endturn()
- end
- end
-
- --------------------------------------------------------------------------------
- -- Projectile: Sub Bomb
- --------------------------------------------------------------------------------
-
- cc.subbomb.subbomb.id=addprojectile("cc.subbomb.subbomb") -- Add Projectile
-
- function cc.subbomb.subbomb.draw(id) -- Draw
- -- Setup draw mode
- setblend(blend_alpha)
- setalpha(0.5)
- setcolor(255,255,255)
- setscale(1,1)
- setrotation(0)
- -- Draw projectile
- drawimage(cc.subbomb.gfx_pro,projectiles[id].x,projectiles[id].y)
- end
-
- function cc.subbomb.subbomb.update(id) -- Update
- -- Move (in substep loop for optimal collision precision)
- msubt=math.ceil(math.max(math.abs(projectiles[id].sx),math.abs(projectiles[id].sy))/4)
- msubx=projectiles[id].sx/msubt
- msuby=projectiles[id].sy/msubt
- explode=0
- for i=1,msubt,1 do
- projectiles[id].x=projectiles[id].x+msubx
- projectiles[id].y=projectiles[id].y+msuby
- -- Surface -> Explode
- if projectiles[id].y<=(getwatery()-10) then
- explode=1
- break
- end
- end
- -- Explode
- if explode==1 then
- -- Cause damage
- arealdamage(projectiles[id].x,projectiles[id].y,175,65)
- -- Destroy terrain
- terrainexplosion(projectiles[id].x,projectiles[id].y,90,1)
- -- Crater
- grey=math.random(0,40)
- terrainalphaimage(gfx_crater200,projectiles[id].x-50,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
- terrainalphaimage(gfx_crater200,projectiles[id].x+50,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
- terrainalphaimage(gfx_crater200,projectiles[id].x,projectiles[id].y-50,math.random(6,9)*0.1,grey,grey,grey)
- -- Effects
- particle(p_waterhit,projectiles[id].x,projectiles[id].y)
- playsound(sfx_hitwater4)
- -- Free projectile
- freeprojectile(id)
- end
- -- Scroll to projectile
- scroll(projectiles[id].x,projectiles[id].y)
- end